package com.honour.busserver.backup.config;

import com.honour.busserver.backup.job.MyJobListener;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

import javax.sql.DataSource;

import static org.quartz.impl.matchers.EverythingMatcher.allJobs;

@Configuration
public class SchedulerConfig {
    @Autowired
    private MyJobListener myJobListener;
    @Autowired
    private SchedulerFactoryBean schedulerFactoryBean;



    @Bean
    public Scheduler scheduler() throws SchedulerException {
        Scheduler scheduler = schedulerFactoryBean.getScheduler();
        scheduler.getListenerManager().addJobListener(myJobListener,allJobs());
        return scheduler;
    }

}
